package com.duoduo.grpc.service.impl;

import com.duoduo.grpc.lib.hello.HelloRequest;
import com.duoduo.grpc.lib.hello.HelloResponse;
import com.duoduo.grpc.lib.hello.HelloServiceGrpc.HelloServiceImplBase;

import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;

@GrpcService
@Slf4j
public class HelloServiceImpl extends HelloServiceImplBase {


    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
        String name = request.getName();
        log.info("received client name is " + name);
        HelloResponse response = HelloResponse.newBuilder().setCode("0000").setMessage("hello "+ name).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
